package javaz.jaxb.xml;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

import javax.xml.bind.JAXBException;

import org.xml.sax.SAXException;

public class ExportXML {
	
	public static void main(String[] args) {

		String xsdLocation = System.getProperty("user.dir") + DataCountry.XSD;
		String dataLocation = System.getProperty("user.dir") + DataCountry.DATA;
		
		DataCountry country = new DataCountry();
		country.getCustomers().add(new DataCustomer());
		country.getCustomers().add(new DataCustomer());
		
		try {
			JaxbWrapper<DataCountry> salesMvtXmlWrapper = new JaxbWrapper<DataCountry>(new File(xsdLocation), DataCountry.class);
			OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(dataLocation), "UTF-8");
			salesMvtXmlWrapper.objectToXml(country, osw);
			osw.close();
		} catch (JAXBException | SAXException | IOException e) {
			e.printStackTrace();
		}
	}

}
